<?php

namespace App\Modules\Article;

use App\Modules\AdapterApi;
use App\Services\Article\ArticleIndex;

/**
 * 文章应用层
 * Class ApiArticle
 * @package App\Modules\Article
 */
class ApiArticle extends AdapterApi
{
//--------------------------------企业站前台开始------------------------------------------

    /**
     * 指定分类下的文章列表
     */
    public function articleList()
    {
        $data = pick_array($this->postData,['cid']);

        return ArticleIndex::ApiArticle()->articleList($data);
    }

    /**
     * 指定分类下的文章详情
     */
    public function assignInfo()
    {
        $data = pick_array($this->postData,['cid']);
        return ArticleIndex::ApiArticle()->assignInfo($data);
    }

    /**
     * 文章详情
     */
    public function articleInfo()
    {
        $data = pick_array($this->postData,['id']);
        return ArticleIndex::ApiArticle()->info($data);
    }

    /**
     * 所有文章列表
     */
    public function allList()
    {
        return ArticleIndex::ApiArticle()->allList();
    }
//--------------------------------企业站前台结束------------------------------------------

    /**
     * 文章添加
     */
    public function add()
    {
        $data = pick_array($this->postData, ['classify_id', 'title', 'content', 'top', 'belong_to', 'img_url']);
        return ArticleIndex::ApiArticle()->add($data);
    }

    /**
     * 文章编辑
     */
    public function edit()
    {
        $data = pick_array($this->postData, ['id', 'classify_id', 'title', 'content', 'top', 'belong_to', 'img_url']);
        return ArticleIndex::ApiArticle()->edit($data);
    }

    /**
     * 删除某篇文章
     * @return mixed
     */
    public function del()
    {
        $data = pick_array($this->postData, ['id']);
        return ArticleIndex::ApiArticle()->del($data);
    }

    /**
     * 恢复启用某篇文章
     */
    public function enable()
    {
        $data = pick_array($this->postData,['id']);

        return ArticleIndex::ApiArticle()->enable($data);
    }

    /**
     * 文章列表
     */
    public function list()
    {
        $data = pick_array($this->postData, ["classify_id", "keywords", "belong_to", "status"]);

        return ArticleIndex::ApiArticle()->list($data);
    }

    /**
     * 文章详情
     */
    public function info()
    {
        $data = pick_array($this->postData, ['id']);
        return ArticleIndex::ApiArticle()->info($data);
    }

    /**
     * 智慧头条下的文章分类和文章列表
     */
    public function witList()
    {
        $data = pick_array($this->postData, ['pid']);
        return ArticleIndex::ApiArticle()->witList($data);
    }

}
